import Vue from 'vue'
import App from './App'
import store from '@/common/store'
import wx from 'jweixin-module'

import uniNavBar from "@/components/uni-nav-bar/uni-nav-bar.vue"
import cuCustom from '@/static/colorui/components/cu-custom.vue'
import Css from './static/css/index.css'
import router from '@/common/router'

import tools from '@/common/utils/tools'
import api from '@/common/request/index'
import { RouterMount } from 'uni-simple-router'

const msg = (title, duration=1500, mask=false, icon='none')=>{
	//统一提示方便全局修改
	if(Boolean(title) === false){ return; }
	uni.showToast({
		title,
		duration,
		mask,
		icon
	});
}

const prePage = ()=>{
	let pages = getCurrentPages();
	let prePage = pages[pages.length - 2];
	// #ifdef H5
	return prePage;
	// #endif
	return prePage.$vm;
}


Vue.component('uni-nav-bar', uniNavBar);
Vue.component('cu-custom', cuCustom);

Vue.config.productionTip = false
Vue.prototype.$store = store;
Vue.prototype.$tools = tools;
// Vue.prototype.$api = api;
Vue.prototype.$api = {msg, prePage, api};
Vue.prototype.$wx = wx

App.mpType = 'app'

const app = new Vue({
	store,
    ...App,
	Css
})


// #ifdef H5
import wxsdk from '@/common/wechat/sdk'
Vue.prototype.$wxsdk = wxsdk;

RouterMount(app, '#app');
// #endif

// #ifndef H5
app.$mount()
// #endif
